<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Client</title>
</head>

<body>
    <script>
        const ws = new WebSocket("ws://localhost:3000/");
        ws.onopen = function () {
            const data = "你好~我是客户端"
            ws.send(data);
            console.log('send:',data);
        };
        ws.onmessage = function (e) {
            //打印服务端返回的消息
            console.log("received: "+e.data);
        }
    </script>
</body>

</html>